<template>
  <view class="points-page">
    <view class="products-list">
      <ProductList :list="pointProducts" />
    </view>
  </view>
</template>

<script lang="ts">
import "./index.less";
import { getProducts } from "../../../services/products-service";
import ProductList from "../components/productList/index.vue";

export default {
  data() {
    return {
      pointProducts: [],
      total: 0,
      totalPage: 0,
      currentPage: 0,
    };
  },
  components: { ProductList },
  methods: {
    setSelectedCategory(category) {
      this.$store.commit("setSelectedCategory", category);
      this.selectedCategory = category;
      this.getProducts(category);
    },
    async getProducts() {
      const res = await getProducts({
        page: 1,
        size: 100,
        is_points_mall: true,
      });
      this.$store.commit("setPointProducts", res.records);
      this.pointProducts = res.records;
      this.total = res.total;
      this.totalPage = res.totalPage;
      console.log(res);
    },
  },

  async created() {},
  async mounted() {
    const { pointProducts } = this.$store.state;
    this.pointProducts = pointProducts;
    this.getProducts();
  },
};
</script>
